home *** CD-ROM | disk | FTP | other *** search
- #include "file interface.h"
- #include "program globals.h"
- #include "window layer.h"
-
- static pascal Boolean CreatorFilterYD(CInfoPBPtr pb, Ptr unused);
-
- Boolean GetSourceFile(FSSpec *sourceFS, ResType theType)
- /* a standard procedure which shows an open dialog box and returns the FSSpec of
- the file you selected (or returns FALSE if you cancelled) */
- {
- StandardFileReply reply;
- SFTypeList theTypes;
- Point where;
- FileFilterYDUPP fileFilterUPP;
-
- DeactivateFloatersAndFirstDocumentWindow();
-
- fileFilterUPP=NewFileFilterYDProc(CreatorFilterYD);
- theTypes[0]=theType;
- where.h=where.v=-1; /* will auto-center dialog */
- // StandardGetFile(0L, 1, theTypes, &reply);
- CustomGetFile(fileFilterUPP, 1, theTypes, &reply, 0, where, 0L, 0L, 0L, 0L, 0L);
- DisposeRoutineDescriptor(fileFilterUPP);
-
- if (reply.sfGood)
- FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name, sourceFS);
-
- ActivateFloatersAndFirstDocumentWindow();
-
- return reply.sfGood; /* TRUE if we have a valid file selected */
- }
-
- Boolean GetDestFile(FSSpec *destFS, Boolean *deleteTheThing, Str255 theTitle)
- /* a standard save dialog box -- given a title (for the prompt), it returns the
- file's FSSpec in destFS and whether a file of that name already exists in
- deleteTheThing (TRUE if file already exists) */
- /* details are pretty much the same as GetSourceFile(), see above */
- {
- StandardFileReply reply;
-
- DeactivateFloatersAndFirstDocumentWindow();
-
- StandardPutFile(theTitle, destFS->name, &reply);
-
- if (reply.sfGood)
- {
- *deleteTheThing=reply.sfReplacing;
- FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name,
- destFS);
- }
-
- ActivateFloatersAndFirstDocumentWindow();
-
- return reply.sfGood;
- }
-
- static pascal Boolean CreatorFilterYD(CInfoPBPtr pb, Ptr unused)
- {
- #pragma unused(unused)
-
- /* returns FALSE if file _should_ be shown; don't ask me why */
- /* so using this file filter in GetSourceFile will only show folders and text files
- with our application's creator */
- return (((pb->hFileInfo.ioFlFndrIn